package com.yufubao.strat.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @description 跨域配置
 * @author zhangyiheng
 * @date 2024/9/4 23:51
 */
@Configuration
public class CorsConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")//项目中的所有接口都支持跨域
                .allowedOriginPatterns("*")//所有地址都可以访问，也可以配置具体地址
                .allowCredentials(true)
                .allowedMethods("*")//"GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS"
                .maxAge(3600);// 跨域允许时间
    }

    public static void main(String[] args) {
        String ss = "expect {, but [, class cn.zhangzhan.common.core.domain.model.LoginUser, offset 1, character [, line 1, column 1, fastjson-version 2.0.53 [\"cn.zhangzhan.common.core.domain.model.LoginUser\",{\"userId\":1,\"deptId\":103,\"token\":\"0816077f-34be-4d64-bd23-b263edfd7acb\",\"loginTime\":1730180768787,\"expireTime\":1730182568787,\"ipaddr\":\"127.0.0.1\",\"loginLocation\":\"内网IP\",\"browser\":\"Firefox 13\",\"os\":\"Windows 10\",\"permissions\":[\"java.util.HashSet\",[\"*:*:*\"]],\"user\":[\"cn.zhangzhan.common.core.domain.entity.SysUser\",{\"createBy\":\"admin\",\"createTime\":[\"java.util.Date\",\"2024-10-28 08:07:55\"],\"updateBy\":null,\"updateTime\":null,\"remark\":\"管理员\",\"userId\":1,\"deptId\":103,\"userName\":\"admin\",\"nickName\":\"若依\",\"email\":\"ry@163.com\",\"phonenumber\":\"15888888888\",\"sex\":\"1\",\"avatar\":\"\",\"password\":\"$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2\",\"status\":\"0\",\"delFlag\":\"0\",\"loginIp\":\"127.0.0.1\",\"loginDate\":[\"java.util.Date\",1730180224000],\"dept\":[\"cn.zhangzhan.common.core.domain.entity.SysDept\",{\"createBy\":null,\"createTime\":null,\"updateBy\":null,\"updateTime\":null,\"remark\":null,\"deptId\":103,\"parentId\":101,\"ancestors\":\"0,100,101\",\"deptName\":\"研发部门\",\"orderNum\":1,\"leader\":\"若依\",\"phone\":null,\"email\":null,\"status\":\"0\",\"delFlag\":null,\"parentName\":null,\"children\":[\"java.util.ArrayList\",[]]}],\"roles\":[\"java.util.ArrayList\",[[\"cn.zhangzhan.common.core.domain.entity.SysRole\",{\"createBy\":null,\"createTime\":null,\"updateBy\":null,\"updateTime\":null,\"remark\":null,\"roleId\":1,\"roleName\":\"超级管理员\",\"roleKey\":\"admin\",\"roleSort\":1,\"dataScope\":\"1\",\"menuCheckStrictly\":false,\"deptCheckStrictly\":false,\"status\":\"0\",\"delFlag\":null,\"flag\":false,\"menuIds\":null,\"deptIds\":null,\"permissions\":null,\"admin\":true}]]],\"roleIds\":null,\"postIds\":null,\"roleId\":null,\"admin\":true}],\"enabled\":true,\"password\":\"$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2\",\"username\":\"admin\",\"authorities\":null,\"accountNonExpired\":true,\"accountNonLocked\":true,\"credentialsNonExpired\":true}]";
    }
}
